<!-- #include file="inc/conn.asp" -->
<%sql="select * from lottery where id="&request("id")
rst.open sql,conn,1,1
if not rst.eof then
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<title><%=rst("title")%></title>
<link rel="stylesheet" type="text/css" href="css/css/hui.css"/>
	<link rel="stylesheet" type="text/css" href="css/style.css"/>
    
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
</head>
<body class="lot_body" >

<%

lot_cnum=rst("cnum")
sql="select * from lottery_list where uid='"&myIP&"' and lot_title='"&rst("title")&"' "
rs.open sql,conn,1,1
my_num=rs.recordcount
rs.close
lot_cnum=lot_cnum-my_num





%>

<div class="lot_fh"><a href="index.asp"><img src="img/1.png"></a></div>
<div class="lot_fr">
 <div id="hui-header-menu" class="hui-icons-nav" style="font-size:16px"></div>
 </div>
 



	<div  class="hui-wrap ">
		
	  <div id="title"><%=rst("title")%> </div>
    
  <div class="time">活动时间：<%=rst("sttime")%>-<%=rst("endtime")%></div>
  <div class="win_num">您还有<b id="cnum"><%=lot_cnum%></b>次抽奖机会
  

  </div>
	<div class="shanDeng" id="deng">
		<div id="luck"><!-- luck -->
        
        <%
		lot_name=split(rst("name"),",")
		lot_pic=split(rst("pic"),",")
		lot_wu=rst("iswu")
		
		%>
<table width="100%" border="0" cellpadding="0" cellspacing="10">
<tr>
<td class="luck-unit luck-unit-0"><%if trim(lot_pic(0))="" then%><h1><%=trim(lot_name(0))%></h1><%else%><img src="<%=trim(lot_pic(0))%>"><%end if%><div class="luck_txt"><%if instr(lot_wu,0)>0 then%>谢谢参与，再来一次吧。<%else%>恭喜您抽中<%=trim(lot_name(0))%><%end if%></div></td>
<td class="luck-unit luck-unit-1"><%if trim(lot_pic(1))="" then%><h1><%=trim(lot_name(1))%></h1><%else%><img src="<%=trim(lot_pic(1))%>"><%end if%><div class="luck_txt"><%if instr(lot_wu,1)>0 then%>谢谢参与，再来一次吧。<%else%>恭喜您抽中<%=trim(lot_name(1))%><%end if%></div></td>
<td class="luck-unit luck-unit-2"><%if trim(lot_pic(2))="" then%><h1><%=trim(lot_name(2))%></h1><%else%><img src="<%=trim(lot_pic(2))%>"><%end if%><div class="luck_txt"><%if instr(lot_wu,2)>0 then%>谢谢参与，再来一次吧。<%else%>恭喜您抽中<%=trim(lot_name(2))%><%end if%></div></td>
</tr>
<tr>
<td class="luck-unit luck-unit-7"><%if trim(lot_pic(7))="" then%><h1><%=trim(lot_name(7))%></h1><%else%><img src="<%=trim(lot_pic(7))%>"><%end if%><div class="luck_txt"><%if instr(lot_wu,7)>0 then%>谢谢参与，再来一次吧。<%else%>恭喜您抽中<%=trim(lot_name(7))%><%end if%></div></td>
<td class="cjBtn" id="btn">立即<br>抽奖</td>
<td class="luck-unit luck-unit-3"><%if trim(lot_pic(3))="" then%><h1><%=trim(lot_name(3))%></h1><%else%><img src="<%=trim(lot_pic(3))%>"><%end if%><div class="luck_txt"><%if instr(lot_wu,3)>0 then%>谢谢参与，再来一次吧。<%else%>恭喜您抽中<%=trim(lot_name(3))%><%end if%></div></td>
</tr>
<tr>
<td class="luck-unit luck-unit-6"><%if trim(lot_pic(6))="" then%><h1><%=trim(lot_name(6))%></h1><%else%><img src="<%=trim(lot_pic(6))%>"><%end if%><div class="luck_txt"><%if instr(lot_wu,6)>0 then%>谢谢参与，再来一次吧。<%else%>恭喜您抽中<%=trim(lot_name(6))%><%end if%></div></td>
<td class="luck-unit luck-unit-5"><%if trim(lot_pic(5))="" then%><h1><%=trim(lot_name(5))%></h1><%else%><img src="<%=trim(lot_pic(5))%>"><%end if%><div class="luck_txt"><%if instr(lot_wu,5)>0 then%>谢谢参与，再来一次吧。<%else%>恭喜您抽中<%=trim(lot_name(5))%><%end if%></div></td>
<td class="luck-unit luck-unit-4"><%if trim(lot_pic(4))="" then%><h1><%=trim(lot_name(4))%></h1><%else%><img src="<%=trim(lot_pic(4))%>"><%end if%><div class="luck_txt"><%if instr(lot_wu,4)>0 then%>谢谢参与，再来一次吧。<%else%>恭喜您抽中<%=trim(lot_name(4))%><%end if%></div></td>
				</tr>
			</table>
		</div><!-- luckEnd -->
	</div>
      <div class="gz">

<%sql="select  * from [lottery] where  id="&request("id") 
rs.open sql,conn,1,1
if not rs.eof then%>
 
<div class="lottery_list"> 



<div class="lot_title">抽奖说明</div>
<div class="lot_con">
<%=replace(rs("info"),vbcrlf,"<br>")%>
 </div>
</div>

<%

end if

rs.close
%>
  </div>
  <div class="win">
      
  </div>
    </div>

<%end if
rst.close
%>

	</div><script>

		var luck={
			index:-1,	//当前转动到哪个位置，起点位置
			count:0,	//总共有多少个位置
			timer:0,	//setTimeout的ID，用clearTimeout清除
			speed:10,	//初始转动速度
			times:0,	//转动次数
			cycle:50,	//转动基本次数：即至少需要转动多少次再进入抽奖环节
			prize:-2,	//中奖位置
			init:function(id){
				if ($("#"+id).find(".luck-unit").length>0) {
					$luck = $("#"+id);
					$units = $luck.find(".luck-unit");
					this.obj = $luck;
					this.count = $units.length;
					$luck.find(".luck-unit-"+this.index).addClass("active");
					
				};
			},

			
			roll:function(){
				var index = this.index;
				var count = this.count;
				var luck = this.obj;
				$(luck).find(".luck-unit-"+index).removeClass("active");
				index += 1;
				if (index>count-1) {
					index = 0;
				};
				$(luck).find(".luck-unit-"+index).addClass("active");
			
				this.index=index;
				return false;
			},
			stop:function(index){
			
				this.prize=index;
				return false;
			}
		};


		function roll(){
			luck.times += 1;
			luck.roll();
			if (luck.times > luck.cycle+10 && luck.prize==luck.index) {
				
				clearTimeout(luck.timer);
				
			

	setTimeout("hui.toast($('.luck-unit-'+luck.index).find('.luck_txt').html());",500); 		 
				luck.prize=-1;
			
				luck.times=0;
				
				click=false;
			}else{
				if (luck.times<luck.cycle) {
					luck.speed -= 10;
				}else if(luck.times==luck.cycle) {
						
				}else{
					if (luck.times > luck.cycle+10 && ((luck.prize==0 && luck.index==7) || luck.prize==luck.index+1)) {
						luck.speed += 110;
					}else{
						luck.speed += 20;
					}
				}
				if (luck.speed<40) {
					luck.speed=40;
				};

				luck.timer = setTimeout(roll,luck.speed);
			}
			return false;
		}







var click=false;
		window.onload=function(){
			luck.init('luck');
			
			$("#btn").click(function() {

        if (click) {
            return false;
        } else {
			
			//按下弹起效果
				$("#btn").addClass("cjBtnDom");
				setTimeout(function(){	
					$("#btn").removeClass("cjBtnDom");
				},200);
			
            //向后端接口发请求返回中奖结果
            var geturl = "inc/bonus.asp?id=<%=request("id")%>"
            $.ajax({　
			url: geturl,
                type: "GET",
                dataType: "json",
                async: false,
                success: function(data) {
			if (data.login == 'ok') {
				  if (data.time == 'no') {
                  hui.iconToast('不在活动时间', 'warn');
					
						
                        return false;
				  }
				
                    if (data.num > 0) {
                   
					  luck.prize = data.prize;
                    $("#cnum").html(data.num-1);
                    luck.speed = 100;
						roll();
                        click = true;
						
						
                        return false;
                    } else {
                        //错误处理
                        if (data.num == 0) {
						 hui.iconToast('抽奖次数已经用完', 'warn');
                        
                        }
					}
                    }else{
						hui.iconToast('请登陆', 'warn');
						
						}
                }
                //function结束
            });
            //ajax结束
      
        //lse结束
    }
});

};

</script>
    
<script type="text/javascript" src="css/js/hui.js"></script>

<script type="text/javascript">
var meuns = ['我的中奖纪录', '后台管理','在线交流'];
var cancel = '关闭菜单';
hui('#hui-header-menu').click(function(){
    hui.actionSheet(meuns, cancel, function(e){
       if(e.index==0){location.href="lottery_list.asp"}
       if(e.index==1){location.href="admin/lottery.asp"}
	    if(e.index==2){location.href="http://book.9416.cn"}
    });
});
</script>



    
</body>
</html>